package com.gxa.user.service.order.util;/**
 * @author JunYu
 * @create 2022-10-09--18:44
 */

import java.math.BigDecimal;

/**
 * @program: take-out-project-shop
 *
 * @description: 输入总价和活动类型，计算优惠了多少钱
 *
 * @author: JunYu
 *
 * @create: 2022-10-09 18:44
 **/

public class GenerateDiscountPrice {
    public static BigDecimal getDiscountPrice(Integer discountType,BigDecimal totalPriceInOrder){
        BigDecimal discountPrice = new BigDecimal(0);
        if(discountType==1)
        {
            if(totalPriceInOrder.compareTo(new BigDecimal(500))>=0)
            {
                discountPrice.add(new BigDecimal(50));
            }
        }
        else if(discountType==2)
        {
            if(totalPriceInOrder.compareTo(new BigDecimal(2000))>=0)
            {
                discountPrice.add(new BigDecimal(250));
            }
            else if(totalPriceInOrder.compareTo(new BigDecimal(1000))>=0&&totalPriceInOrder.compareTo(new BigDecimal(2000))<0)
            {
                discountPrice.add(new BigDecimal(120));
            }
            else if(totalPriceInOrder.compareTo(new BigDecimal(500))>=0&&totalPriceInOrder.compareTo(new BigDecimal(1000))<0)
            {
                discountPrice.add(new BigDecimal(50));
            }
            else if(totalPriceInOrder.compareTo(new BigDecimal(300))>=0&&totalPriceInOrder.compareTo(new BigDecimal(500))<0)
            {
                discountPrice.add(new BigDecimal(30));
            }
            else if(totalPriceInOrder.compareTo(new BigDecimal(100))>=0&&totalPriceInOrder.compareTo(new BigDecimal(300))<0)
            {
                discountPrice.add(new BigDecimal(10));
            }

        }
        return discountPrice;
    }
}
